%*******************************************************************************
%*
%*   Copyright ©2009 Alexandru Marin
%*
%*   This file is part of nwave/pMRI C library.
%*
%*   This project started as an MSc degree project during a
%*   stage at the Paris-Est university, under joint supervision of prof.
%*   Bogdan Ionescu (Image Analysis and Processing Laboratory, "Politehica"
%*   University of Bucharest), Caroline Chaux and Jean-Christophe Pesquet
%*   (Laboratoire d'Informatique, Université Paris-Est, Institut Gaspard Monge).
%*
%*   nwave/pMRI C libray is free software: you can redistribute it and/or modify
%*   it under the terms of the GNU General Public License as published by
%*   the Free Software Foundation, either version 2 of the License, or
%*   (at your option) any later version.
%*
%*   nwave/pMRI C libray is distributed in the hope that it will be useful,
%*   but WITHOUT ANY WARRANTY; without even the implied warranty of
%*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%*   GNU General Public License for more details.
%*
%*   You should have received a copy of the GNU General Public License
%*   along with nwave/pMRI C library. If not, see <http://www.gnu.org/licenses/>
%*
%*******************************************************************************


load mri.mat/I2D
load mri.mat/S2D

I2D = 255*abs(I2D)/max(abs(I2D(:)));
I2D_fft = fftshift(fft2(abs(I2D)));

% generate fullsized images
imwrite(uint8(abs(I2D)), 'I2D.png');
imwrite(uint8(abs(I2D_fft/50)), 'I2D_fft.png');

% generate undersampled images
for r=[2 4]
    I2D_fft_unders = I2D_fft(1:r:end, :);
    I2D_unders = abs(ifft2(fftshift(I2D_fft_unders)));
    imwrite(uint8(abs(I2D_fft_unders/50)), ['I2D_ksp_R' num2str(r) '.png']);
    imwrite(uint8(abs(I2D_unders)), ['I2D_R' num2str(r) '.png']);
end


% generate sensitivity matrix
for l=[1 2 3 4 5 6 7 8]
   Stemp = S2D(:,:,l);
   Stemp = 255*abs(Stemp)/max(abs(Stemp(:)));
   imwrite(uint8(Stemp), ['S2D_L' num2str(l) '.png']);
end

